package cn.qicaiwang.open.common.utils;

import java.util.HashMap;
import java.util.Map;

public class ProvinceUtil {
    private static final Map<String, String> PROVINCE_MAPPING = new HashMap<>();

    static {
        // 直辖市
        PROVINCE_MAPPING.put("北京", "beijing");
        PROVINCE_MAPPING.put("上海", "shanghai");
        PROVINCE_MAPPING.put("天津", "tianjin");
        PROVINCE_MAPPING.put("重庆", "chongqing");

        // 省份
        PROVINCE_MAPPING.put("河北", "hebei");
        PROVINCE_MAPPING.put("山西", "shanxi");
        PROVINCE_MAPPING.put("辽宁", "liaoning");
        PROVINCE_MAPPING.put("吉林", "jilin");
        PROVINCE_MAPPING.put("黑龙江", "heilongjiang");
        PROVINCE_MAPPING.put("江苏", "jiangsu");
        PROVINCE_MAPPING.put("浙江", "zhejiang");
        PROVINCE_MAPPING.put("安徽", "anhui");
        PROVINCE_MAPPING.put("福建", "fujian");
        PROVINCE_MAPPING.put("江西", "jiangxi");
        PROVINCE_MAPPING.put("山东", "shandong");
        PROVINCE_MAPPING.put("河南", "henan");
        PROVINCE_MAPPING.put("湖北", "hubei");
        PROVINCE_MAPPING.put("湖南", "hunan");
        PROVINCE_MAPPING.put("广东", "guangdong");
        PROVINCE_MAPPING.put("海南", "hainan");
        PROVINCE_MAPPING.put("四川", "sichuan");
        PROVINCE_MAPPING.put("贵州", "guizhou");
        PROVINCE_MAPPING.put("云南", "yunnan");
        PROVINCE_MAPPING.put("陕西", "shaanxi"); // 山西和陕西拼音相同，需区分
        PROVINCE_MAPPING.put("甘肃", "gansu");
        PROVINCE_MAPPING.put("青海", "qinghai");

        // 自治区
        PROVINCE_MAPPING.put("内蒙古", "neimenggu");
        PROVINCE_MAPPING.put("广西", "guangxi");
        PROVINCE_MAPPING.put("西藏", "xizang");
        PROVINCE_MAPPING.put("宁夏", "ningxia");
        PROVINCE_MAPPING.put("新疆", "xinjiang");


    }


    public static String getProvinceCode(String provinceName) {
        String code = PROVINCE_MAPPING.get(provinceName);
        return code != null ? code : "common";
    }
}